package com.eduction.modules.system.dao;

import com.eduction.common.dbutil.DbHelper;
import com.eduction.modules.system.entity.ApplyFileBaseDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;

@Repository
public class ApplyFileBaseDetailRepository {

	@Autowired
	private DbHelper dbHelper;

	@Autowired
	private ApplyFileBaseDetailDao applyFileBaseDetailDao;


	/**
	 * 查询学校自评表基础信息详情
	 * @throws SQLException
	 */
	public ApplyFileBaseDetail queryApplyFileBaseDetailBySchoolId(String schoolId) throws SQLException{
		String sql = "SELECT * FROM t_apply_file_base_detail where school_id = ? ";
		return dbHelper.getBean(sql, ApplyFileBaseDetail.class, schoolId);

	}

	/**
	 * 保存该校的自评表基础信息详情
	 */
	public void saveAppplyFileBaseDetail(ApplyFileBaseDetail a) throws SQLException{
		ApplyFileBaseDetail base=queryApplyFileBaseDetailBySchoolId(a.getSchoolId());
		if(base!=null&&base.getId()!=null){
			applyFileBaseDetailDao.delete(base.getId());
		}
		applyFileBaseDetailDao.save(a);
	}

//	public void deleteApplyFile(String pId) {
//		applyFileBaseDao.delete(pId);
//	}
}
